//
//  XLMainViewController.swift
//  微博
//
//  Created by macbook on 16/9/28.
//  Copyright © 2016年 buWangChuXing. All rights reserved.
//

import UIKit

class XLMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //自定义tabBar
        let tab = XLTabBar()
        tab.XLTabbarDelegate = self
        //通过kvc赋值
        setValue(tab, forKey: "tabBar")

        addChildViewController(XLHomeTableViewController(), title: "首页", imageName: "tabbar_home");
        addChildViewController(XLHomeTableViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(XLHomeTableViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(XLHomeTableViewController(), title: "我", imageName: "tabbar_profile")
    }

    
    func addChildViewController(vc: UIViewController,title: NSString,imageName:String) {
        
        vc.title = title as String
        
        vc.tabBarItem.image = UIImage(named: imageName);
        vc.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")
        let navC = UINavigationController(rootViewController: vc)
        addChildViewController(navC);
        
    }
}

//中间弹出的按钮
extension XLMainViewController:XLTabBarDelegate{

    func composeBtnClickPushController() {
        
      print("弹出控制器")
    }
    
    
}










